package com.bw.library.mvp.view;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import com.bw.library.mvp.presenter.IPresenter;



public abstract class BaseFragment<P extends IPresenter> extends Fragment implements IFragment {

    protected P mpresenter;
    private View mView;
    @Override
    public View onCreateView(@NonNull  LayoutInflater inflater, @Nullable  ViewGroup container, @Nullable  Bundle savedInstanceState) {
        return mView=inflater.inflate(bandLayout(),container,false);
    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        initView();
        initData();
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        if (mpresenter!=null){
            mpresenter.destory();
            mpresenter=null;
        }
    }

    @Override
    public <T extends View> T findViewById(int id) {
        return mView.findViewById(id);
    }
}
